package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ComplaintInfo;
import com.ruoyi.system.service.IComplaintInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投诉信息Controller
 * 
 * @author LK
 * @date 2024-06-22
 */
@RestController
@RequestMapping("/system/complaint_info")
public class ComplaintInfoController extends BaseController
{
    @Autowired
    private IComplaintInfoService complaintInfoService;

    /**
     * 查询投诉信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComplaintInfo complaintInfo)
    {
        startPage();
        List<ComplaintInfo> list = complaintInfoService.selectComplaintInfoList(complaintInfo);
        return getDataTable(list);
    }

    /**
     * 导出投诉信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:export')")
    @Log(title = "投诉信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComplaintInfo complaintInfo)
    {
        List<ComplaintInfo> list = complaintInfoService.selectComplaintInfoList(complaintInfo);
        ExcelUtil<ComplaintInfo> util = new ExcelUtil<ComplaintInfo>(ComplaintInfo.class);
        util.exportExcel(response, list, "投诉信息数据");
    }

    /**
     * 获取投诉信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:query')")
    @GetMapping(value = "/{complaintId}")
    public AjaxResult getInfo(@PathVariable("complaintId") String complaintId)
    {
        return success(complaintInfoService.selectComplaintInfoByComplaintId(complaintId));
    }

    /**
     * 新增投诉信息
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:add')")
    @Log(title = "投诉信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComplaintInfo complaintInfo)
    {
        return toAjax(complaintInfoService.insertComplaintInfo(complaintInfo));
    }

    /**
     * 修改投诉信息
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:edit')")
    @Log(title = "投诉信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComplaintInfo complaintInfo)
    {
        return toAjax(complaintInfoService.updateComplaintInfo(complaintInfo));
    }

    /**
     * 删除投诉信息
     */
    @PreAuthorize("@ss.hasPermi('system:complaint_info:remove')")
    @Log(title = "投诉信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintIds}")
    public AjaxResult remove(@PathVariable String[] complaintIds)
    {
        return toAjax(complaintInfoService.deleteComplaintInfoByComplaintIds(complaintIds));
    }
}
